import axios from 'axios'

export function getAPI(params) {
  return axios({
    url: 'http://localhost:3001/data',
    method: 'GET',
    params
  })
}
// 删除
export function delAPI(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: 'DELETE',
    params: id
  })
}

// 新增
export function addAPI(data) {
  return axios({
    url: 'http://localhost:3001/data',
    method: 'POST',
    data
  })
}

// 修改
export function updatAPI(data) {
  return axios({
    url: `http://localhost:3001/data/${data.id}`,
    method: 'PUT',
    data: data
  })
}

// 获取详情
export function gettAPI(id) {
  return axios({
    url: `http://localhost:3001/data/${id}`,
    method: 'GET'
  })
}
// 搜索
export function searchAPI(username) {
  return axios({
    url: `http://localhost:3001/data/?name=${username}`,
    method: 'GET'
  })
}
